package com.sgzn.sgpay.service.impl;

import com.sgzn.sgpay.enums.DeviceType;
import com.sgzn.sgpay.model.request.SgsDeviceIncomePreInfoRequest;
import com.sgzn.sgpay.model.response.SgsResultResponse;
import com.sgzn.sgpay.model.response.result.SgsDeviceIncomePreInfoResult;
import com.sgzn.sgpay.model.response.vo.DeviceTypeVo;
import com.sgzn.sgpay.service.SgsDeviceIncomePreInfoService;
import com.sgzn.sgpay.service.support.SgsResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 设备收益前查询展示信息服务实现类
 * @author huangsenguang
 * @version Id: SgsDeviceIncomePreInfoServiceImpl.java, v 0.1 2018/5/30 13:51 huangsenguang Exp $$
 */
@Slf4j
@Service
public class SgsDeviceIncomePreInfoServiceImpl implements SgsDeviceIncomePreInfoService {
    @Override
    public SgsResultResponse<SgsDeviceIncomePreInfoResult> queryInfo(SgsDeviceIncomePreInfoRequest request) {
        SgsDeviceIncomePreInfoResult result = getSgsDeviceIncomePreInfoResult(this.getDeviceTypeMap());
        return SgsResponseUtil.INSTANCE.success(result);
    }

    private SgsDeviceIncomePreInfoResult getSgsDeviceIncomePreInfoResult(List<DeviceTypeVo> deviceTypeList) {
        SgsDeviceIncomePreInfoResult result = new SgsDeviceIncomePreInfoResult();
        result.setDeviceTypeList(deviceTypeList);
        return result;
    }

    /**
     * 获取设备类型
     * @return
     */
    private List<DeviceTypeVo> getDeviceTypeMap() {
        List<DeviceTypeVo> list = new ArrayList<>(2);
        for(DeviceType single : DeviceType.values()){
            DeviceTypeVo deviceTypeVo = new DeviceTypeVo();
            deviceTypeVo.setCode(single.getCode());
            deviceTypeVo.setName(single.getDesc());
            list.add(deviceTypeVo);
        }
        return list;
    }
}

